<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Mailman</title>
<link rel="stylesheet" type="text/css" href="../C.css">
<script type="text/javascript" src="../jquery.js"></script><script type="text/javascript" src="../jquery.syntax.js"></script><script type="text/javascript" src="../yelp.js"></script>
</head>
<body id="home">
<!--<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">
        _uacct = "UA-1018242-8";
        urchinTracker();
      </script><script>
      function englishPageVersion() {
        var href = window.location.href;
        if (href.slice(-1) == "/") {
                window.location = "index.html.en";
        } else {
                window.location = href.replace(/\.html.*/, ".html.en");
        }
         return false;
      }
      function browserPreferredLanguage() {
        var href = window.location.href;
        if (href.slice(-1) == "/") {
                window.location = href;
        } else {
                window.location = href.replace(/\.html.*/, ".html");
        }
        return false;
      }
      </script>--><div id="container">
<div id="container-inner">
<div id="mothership"><ul>
<li><a href="https://partners.ubuntu.com">Partners</a></li>
<li><a href="https://www.ubuntu.com/support/community-support">Support</a></li>
<li><a href="https://community.ubuntu.com">Community</a></li>
<li><a href="https://www.ubuntu.com">Ubuntu.com</a></li>
</ul></div>
<div id="header">
<h1 id="ubuntu-header"><a href="https://help.ubuntu.com/">Ubuntu Documentation</a></h1>
<ul id="main-menu">
<li><a class="main-menu-item current" href="https://help.ubuntu.com/">Official Documentation</a></li>
<li><a href="https://help.ubuntu.com/community/CommunityHelpWiki">Community Help Wiki</a></li>
<li><a href="https://community.ubuntu.com/t/contribute/26">Contribute</a></li>
</ul>
</div>
<div id="menu-search"><div id="search-box">
<noscript><form action="https://www.google.com/cse" id="cse-search-box"><div>
<input type="hidden" name="cx" value="003883529982892832976:e2vwumte3fq"><input type="hidden" name="ie" value="UTF-8"><input type="text" name="q" size="21"><input type="submit" name="sa" value="Search">
</div></form></noscript><!--
<script>
                document.write('<form action="https://help.ubuntu.com/search.html" id="cse-search-box">');
                document.write('  <div>');
                document.write('    <input type="hidden" name="cof" value="FORID:9">');
                document.write('    <input type="hidden" name="cx" value="003883529982892832976:e2vwumte3fq">');
                document.write('    <input type="hidden" name="ie" value="UTF-8">');
                document.write('    <input type="text" name="q" size="21">');
                document.write('    <input type="submit" name="sa" value="Search">');
                document.write('  </div>');
                document.write('</form>');
              </script>-->
</div></div>
<div class="trails"><div class="trail">
<a href="https://help.ubuntu.com/18.04" class="trail">Ubuntu 18.04</a> » <a class="trail" href="../index.html" title="Ubuntu Server Guide">Ubuntu Server Guide</a> » <a class="trail" href="email-services.html" title="Email Services">Email Services</a> » </div></div>
<div id="cwt-content" class="clearfix content-area"><div id="page">
<div id="content">
<div class="links nextlinks">
<a class="nextlinks-prev" href="dovecot-server.html" title="Dovecot Server">Previous</a><a class="nextlinks-next" href="mail-filtering.html" title="Mail Filtering">Next</a>
</div>
<div class="hgroup"><h1 class="title">Mailman</h1></div>
<div class="region">
<div class="contents"><p class="para">
          Mailman is an open source program for managing electronic mail
          discussions and e-newsletter lists. Many open source mailing
          lists (including all the <a href="http://lists.ubuntu.com" class="ulink" title="http://lists.ubuntu.com">Ubuntu mailing lists</a>) use
          Mailman as their mailing list software. It is powerful and easy
          to install and maintain.
          </p></div>
<div class="links sectionlinks" role="navigation"><ul>
<li class="links"><a class="xref" href="mailman.html#mailman-installation" title="Installation">Installation</a></li>
<li class="links"><a class="xref" href="mailman.html#mailman-configuration" title="Configuration">Configuration</a></li>
<li class="links"><a class="xref" href="mailman.html#mailman-admin" title="Administration">Administration</a></li>
<li class="links"><a class="xref" href="mailman.html#mailman-users" title="Users">Users</a></li>
<li class="links"><a class="xref" href="mailman.html#mailman-references" title="References">References</a></li>
</ul></div>
<div class="sect2 sect" id="mailman-installation"><div class="inner">
<div class="hgroup"><h2 class="title">Installation</h2></div>
<div class="region">
<div class="contents">
<p class="para">
			Mailman provides a web interface for the administrators and users,
			using an external mail server to send and receive emails. It works
			perfectly with the following mail servers:
            </p>
<p class="para">
            <div class="list itemizedlist"><ul class="list itemizedlist compact">
<li class="list itemizedlist">
                    <p class="para"><span class="app application">Postfix</span></p>
                </li>
<li class="list itemizedlist">
                    <p class="para"><span class="app application">Exim</span></p>
                </li>
<li class="list itemizedlist">
                    <p class="para"><span class="app application">Sendmail</span></p>
                </li>
<li class="list itemizedlist">
                    <p class="para"><span class="app application">Qmail</span></p>
                </li>
</ul></div>
            </p>
<p class="para">
            We will see how to install and configure Mailman with, the Apache web server,
            and either the Postfix or Exim mail server. If you wish to install Mailman
            with a different mail server, please refer to the references
            section. 
            </p>
<div class="note" title="Note"><div class="inner"><div class="region"><div class="contents">
	       <p class="para">
		You only need to install one mail server and <span class="app application">Postfix</span> is the default Ubuntu Mail Transfer Agent.
	       </p>
	     </div></div></div></div>
</div>
<div class="sect3 sect" id="mailman-apache2"><div class="inner">
<div class="hgroup"><h3 class="title">Apache2</h3></div>
<div class="region"><div class="contents"><p class="para">
                To install apache2 you refer to <a class="xref" href="httpd.html#http-installation" title="Installation">Installation</a> for details.
              </p></div></div>
</div></div>
<div class="sect3 sect" id="mailman-postfix"><div class="inner">
<div class="hgroup"><h3 class="title">Postfix</h3></div>
<div class="region"><div class="contents"><p class="para">
	    For instructions on installing and configuring Postfix refer to <a class="xref" href="postfix.html" title="Postfix">Postfix</a>
	    </p></div></div>
</div></div>
<div class="sect3 sect" id="mailman-exim4"><div class="inner">
<div class="hgroup"><h3 class="title">Exim4</h3></div>
<div class="region"><div class="contents">
<p class="para">
              To install Exim4 refer to <a class="xref" href="exim4.html" title="Exim4">Exim4</a>.
	      </p>
<p class="para">
	      Once exim4 is installed, the configuration files are stored in
	      the <span class="file filename">/etc/exim4</span> directory. In Ubuntu, by default, the exim4 configuration files are
	      split across different files. You can change this behavior by changing
	      the following variable in the <span class="file filename">/etc/exim4/update-exim4.conf</span> file:
          </p>
<div class="code"><pre class="contents ">dc_use_split_config='true'
</pre></div>
</div></div>
</div></div>
<div class="sect3 sect" id="mailman-mailman"><div class="inner">
<div class="hgroup"><h3 class="title">Mailman</h3></div>
<div class="region"><div class="contents">
<p class="para">
              To install <span class="app application">Mailman</span>, run following command at a terminal prompt:
	      </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo apt install mailman</span> 
</pre></div>
<p class="para">
	     It copies the installation files in
	     <span class="app application">/var/lib/mailman</span> directory. It installs the
	     CGI scripts in <span class="app application">/usr/lib/cgi-bin/mailman</span>
	     directory.  It creates <span class="em emphasis">list</span> linux
	     user. It creates the <span class="em emphasis">list</span> linux
 	     group. The mailman process will be owned by this user. 
             </p>
</div></div>
</div></div>
</div>
</div></div>
<div class="sect2 sect" id="mailman-configuration"><div class="inner">
<div class="hgroup"><h2 class="title">Configuration</h2></div>
<div class="region">
<div class="contents"><p class="para">
            This section assumes you have successfully installed
            <span class="app application">mailman</span>,
            <span class="app application">apache2</span>, and
	    <span class="app application">postfix</span> or <span class="app application">exim4</span>. Now you just need
            to configure them. 
            </p></div>
<div class="sect3 sect" id="mailman-conf-apache2"><div class="inner">
<div class="hgroup"><h3 class="title">Apache2</h3></div>
<div class="region"><div class="contents">
<p class="para">
	      An example Apache configuration file comes with <span class="app application">Mailman</span> and is placed
	      in <span class="file filename">/etc/mailman/apache.conf</span>. In order for Apache to use the config file it needs
	      to be copied to <span class="file filename">/etc/apache2/sites-available</span>:
	      </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo cp /etc/mailman/apache.conf /etc/apache2/sites-available/mailman.conf</span>
</pre></div>
<p class="para">
	      This will setup a new Apache <span class="em emphasis">VirtualHost</span> for the Mailman administration site.
	      Now enable the new configuration and restart Apache:
	      </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo a2ensite mailman.conf</span>
<span class="cmd command">sudo systemctl restart apache2.service</span>
</pre></div>
<p class="para">
	      Mailman uses apache2 to render its CGI scripts. The mailman CGI scripts
	      are installed in the <span class="app application">/usr/lib/cgi-bin/mailman</span>
	      directory. So, the mailman url will be
	      http://hostname/cgi-bin/mailman/. You can make changes to the
	      <span class="file filename">/etc/apache2/sites-available/mailman.conf</span> file if you wish to
	      change this behavior.
              </p>
</div></div>
</div></div>
<div class="sect3 sect" id="mailman-conf-postfix"><div class="inner">
<div class="hgroup"><h3 class="title">Postfix</h3></div>
<div class="region"><div class="contents">
<p class="para">
	    For <span class="app application">Postfix</span> integration, we will associate the domain lists.example.com with the mailing lists.
	    Please replace <span class="em emphasis">lists.example.com</span> with the domain of your choosing.
	    </p>
<p class="para">
	    You can use the postconf command to add the necessary configuration to <span class="file filename">/etc/postfix/main.cf</span>:
	    </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo postconf -e 'relay_domains = lists.example.com'</span>
<span class="cmd command">sudo postconf -e 'transport_maps = hash:/etc/postfix/transport'</span>
<span class="cmd command">sudo postconf -e 'mailman_destination_recipient_limit = 1'</span>
</pre></div>
<p class="para">
	  In <span class="file filename">/etc/postfix/master.cf</span> double check that you have the following transport:
	  </p>
<div class="code"><pre class="contents ">mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}
</pre></div>
<p class="para">
	  It calls the <span class="em emphasis">postfix-to-mailman.py</span> script when a mail is delivered to a list.
	  </p>
<p class="para">
	  Associate the domain lists.example.com to the Mailman transport with the transport map. Edit the file <span class="file filename">/etc/postfix/transport</span>: 
	  </p>
<div class="code"><pre class="contents ">lists.example.com      mailman:
</pre></div>
<p class="para">
	  Now have <span class="app application">Postfix</span> build the transport map by entering the following from a terminal prompt:
	  </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo postmap -v /etc/postfix/transport</span>
</pre></div>
<p class="para">
	  Then restart Postfix to enable the new configurations:
	  </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo systemctl restart postfix.service</span>
</pre></div>
</div></div>
</div></div>
<div class="sect3 sect" id="mailman-conf-exim4"><div class="inner">
<div class="hgroup"><h3 class="title">Exim4</h3></div>
<div class="region"><div class="contents">
<p class="para">
              Once Exim4 is installed, you can start the Exim server using the following
              command from a terminal prompt:
	      </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo systemctl start exim4.service</span>
</pre></div>
<p class="para">
In order to make mailman work with Exim4, you need to configure Exim4.
As mentioned earlier, by default, Exim4 uses multiple configuration
files of different types. For details, please refer to the <a href="http://www.exim.org" class="ulink" title="http://www.exim.org">Exim</a> web site.  To run mailman, we
should add new a configuration file to the following configuration
types: 
              <div class="list itemizedlist"><ul class="list itemizedlist compact">
<li class="list itemizedlist">
                <p class="para">Main</p>
              </li>
<li class="list itemizedlist">
                <p class="para">Transport</p>
              </li>
<li class="list itemizedlist">
                <p class="para">Router</p>
              </li>
</ul></div>
              Exim creates a master configuration file by sorting all
              these mini configuration files. So, the order of these
              configuration files is very important.
              </p>
</div></div>
</div></div>
<div class="sect3 sect" id="mailman-conf-main"><div class="inner">
<div class="hgroup"><h3 class="title">Main</h3></div>
<div class="region"><div class="contents"><p class="para">
              All the configuration files belonging to the main type are
              stored in the
              <span class="file filename">/etc/exim4/conf.d/main/</span> directory. You can add
              the following content to a new file, named <span class="file filename">04_exim4-config_mailman</span>:

<div class="code"><pre class="contents "># start
# Home dir for your Mailman installation -- aka Mailman's prefix
# directory.
# On Ubuntu this should be "/var/lib/mailman"
# This is normally the same as ~mailman
MM_HOME=/var/lib/mailman
#
# User and group for Mailman, should match your --with-mail-gid
# switch to Mailman's configure script.  Value is normally "mailman"
MM_UID=list
MM_GID=list
#
# Domains that your lists are in - colon separated list
# you may wish to add these into local_domains as well
domainlist mm_domains=hostname.com
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# These values are derived from the ones above and should not need
# editing unless you have munged your mailman installation
#
# The path of the Mailman mail wrapper script
MM_WRAP=MM_HOME/mail/mailman
#
# The path of the list config file (used as a required file when
# verifying list addresses)
MM_LISTCHK=MM_HOME/lists/${lc::$local_part}/config.pck
# end
</pre></div>
          </p></div></div>
</div></div>
<div class="sect3 sect" id="mailman-conf-transport"><div class="inner">
<div class="hgroup"><h3 class="title">Transport</h3></div>
<div class="region"><div class="contents"><p class="para">
All the configuration files belonging to transport type are stored in
the <span class="file filename">/etc/exim4/conf.d/transport/</span> directory. You
can add the following content to a new file named <span class="file filename">
40_exim4-config_mailman</span>:

<div class="code"><pre class="contents ">  mailman_transport:
   driver = pipe
   command = MM_WRAP \
               '${if def:local_part_suffix \
                     {${sg{$local_part_suffix}{-(\\w+)(\\+.*)?}{\$1}}} \
                     {post}}' \
               $local_part
    current_directory = MM_HOME
    home_directory = MM_HOME
    user = MM_UID
    group = MM_GID
</pre></div>
              </p></div></div>
</div></div>
<div class="sect3 sect" id="mailman-conf-router"><div class="inner">
<div class="hgroup"><h3 class="title">Router</h3></div>
<div class="region"><div class="contents">
<p class="para">
All the configuration files belonging to router type are stored in the
<span class="file filename">/etc/exim4/conf.d/router/</span> directory. You can add the following content
in to a new file named <span class="file filename">101_exim4-config_mailman</span>:
<div class="code"><pre class="contents ">  mailman_router:
   driver = accept
   require_files = MM_HOME/lists/$local_part/config.pck
   local_part_suffix_optional
   local_part_suffix = -bounces : -bounces+* : \
                       -confirm+* : -join : -leave : \
                       -owner : -request : -admin
   transport = mailman_transport
</pre></div>

              </p>
<div class="note note-warning" title="Warning"><div class="inner"><div class="region"><div class="contents">
<p class="para">
The order of main and transport configuration files can be in any order.
But, the order of router configuration files must be the same.
This particular file must appear before the
<span class="app application">200_exim4-config_primary</span> file.
These two configuration files contain same type of information. The
first file takes the precedence. For more details, please refer to the
references section.
</p>
</div></div></div></div>
</div></div>
</div></div>
<div class="sect3 sect" id="mailman-conf-mailman"><div class="inner">
<div class="hgroup"><h3 class="title">Mailman</h3></div>
<div class="region"><div class="contents">
<p class="para">
	      Once mailman is installed, you can run it using the following command:
	      </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo systemctl start mailman.service</span>
</pre></div>
<p class="para">
	      Once mailman is installed, you should create the default mailing list.
	      Run the following command to create the mailing list:
	      </p>
<div class="screen"><pre class="contents "><span class="cmd command">sudo /usr/sbin/newlist mailman</span>
</pre></div>
<div class="code"><pre class="contents ">  Enter the email address of the person running the list: bhuvan at ubuntu.com
  Initial mailman password:
  To finish creating your mailing list, you must edit your <span class="file filename">/etc/aliases</span> (or
  equivalent) file by adding the following lines, and possibly running the
  `newaliases' program:

  ## mailman mailing list
  mailman:              "|/var/lib/mailman/mail/mailman post mailman"
  mailman-admin:        "|/var/lib/mailman/mail/mailman admin mailman"
  mailman-bounces:      "|/var/lib/mailman/mail/mailman bounces mailman"
  mailman-confirm:      "|/var/lib/mailman/mail/mailman confirm mailman"
  mailman-join:         "|/var/lib/mailman/mail/mailman join mailman"
  mailman-leave:        "|/var/lib/mailman/mail/mailman leave mailman"
  mailman-owner:        "|/var/lib/mailman/mail/mailman owner mailman"
  mailman-request:      "|/var/lib/mailman/mail/mailman request mailman"
  mailman-subscribe:    "|/var/lib/mailman/mail/mailman subscribe mailman"
  mailman-unsubscribe:  "|/var/lib/mailman/mail/mailman unsubscribe mailman"

  Hit enter to notify mailman owner...

  # 
</pre></div>
<p class="para">
	     We have configured either Postfix or Exim4 to recognize all emails from mailman. So, it is
	     not mandatory to make any new entries in
	     <span class="file filename">/etc/aliases</span>.  If you have made any changes
	     to the configuration files, please ensure that you restart those
	     services before continuing to next section.
	     </p>
<div class="note" title="Note"><div class="inner"><div class="region"><div class="contents">
         <p class="para">
         The Exim4 does not use the above aliases to forward mails to
         Mailman, as it uses a <span class="em emphasis">discover</span> approach. To
         suppress the aliases while creating the list, you can add
         <span class="em emphasis">MTA=None</span> line in Mailman configuration
         file, <span class="file filename">/etc/mailman/mm_cfg.py</span>.
         </p>
         </div></div></div></div>
</div></div>
</div></div>
</div>
</div></div>
<div class="sect2 sect" id="mailman-admin"><div class="inner">
<div class="hgroup"><h2 class="title">Administration</h2></div>
<div class="region"><div class="contents">
<p class="para">
We assume you have a default installation. The
mailman cgi scripts are still in the
<span class="app application">/usr/lib/cgi-bin/mailman/</span> directory.  Mailman
provides a web based administration facility. To access this page, point
your browser to the following url: 

</p>
<p class="para">
http://hostname/cgi-bin/mailman/admin
</p>
<p class="para">
The default mailing list, <span class="em emphasis">mailman</span>,
will appear in this screen. If you click the mailing list name, it
will ask for your authentication password.  If you enter the correct
password, you will be able to change administrative settings of this
mailing list.

You can create a new mailing list using the command line utility
(<span class="cmd command">/usr/sbin/newlist</span>).
Alternatively, you can create a new mailing list using the web interface. 
</p>
</div></div>
</div></div>
<div class="sect2 sect" id="mailman-users"><div class="inner">
<div class="hgroup"><h2 class="title">Users</h2></div>
<div class="region"><div class="contents">
<p class="para">
Mailman provides a web based interface for users. To access this page,
point your browser to the following url:
</p>
<p class="para">
http://hostname/cgi-bin/mailman/listinfo
</p>
<p class="para">
The default mailing list, <span class="em emphasis">mailman</span>,
will appear in this screen. If you
click the mailing list name, it will display the subscription form. You
can enter your email address, name (optional), and password to subscribe.
An email invitation will be sent to you. You can follow the
instructions in the email to subscribe.
</p>
</div></div>
</div></div>
<div class="sect2 sect" id="mailman-references"><div class="inner">
<div class="hgroup"><h2 class="title">References</h2></div>
<div class="region"><div class="contents">
<p class="para">
<a href="http://www.list.org/mailman-install/index.html" class="ulink" title="http://www.list.org/mailman-install/index.html"> GNU Mailman
- Installation Manual</a>
</p>
<p class="para">
<a href="http://www.exim.org/howto/mailman21.html" class="ulink" title="http://www.exim.org/howto/mailman21.html">HOWTO - Using Exim
4 and Mailman 2.1 together</a>
</p>
<p class="para">
          Also, see the <a href="https://help.ubuntu.com/community/Mailman" class="ulink" title="https://help.ubuntu.com/community/Mailman">Mailman Ubuntu Wiki</a> page.
          </p>
</div></div>
</div></div>
</div>
<div class="links nextlinks">
<a class="nextlinks-prev" href="dovecot-server.html" title="Dovecot Server">Previous</a><a class="nextlinks-next" href="mail-filtering.html" title="Mail Filtering">Next</a>
</div>
<div class="clear"></div>
</div>
<div id="pagebottom"></div>
</div></div>
</div>
<div id="footer"><p>The material in this document is available under a free license, see <a href="https://help.ubuntu.com/legal.html">Legal</a> for details.<br>
          For information on contributing see the <a href="https://wiki.ubuntu.com/DocumentationTeam">Ubuntu Documentation Team wiki page</a>.
          To report errors in this serverguide documentation, <a href="https://bugs.launchpad.net/serverguide">file a bug report</a>.</p></div>
</div>
</body>
</html>
